package com.qinghong.blog.controller;


import com.google.common.collect.Lists;
import com.qinghong.blog.constant.StatusConst;
import com.qinghong.blog.entity.Menu;
import com.qinghong.blog.service.IMenuService;
import com.qinghong.blog.vo.ConditionVO;
import com.qinghong.blog.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qinghong
 * @since 2021-12-06
 */
@RestController
@Api(tags = "菜单模块")
public class MenuController {

    @Autowired
    private IMenuService menuService;

    // TODO 条件查询 redis缓存
    @ApiOperation(value = "查看菜单列表")
    @GetMapping("/admin/menus")
    public Result<List<Menu>> listMenus(ConditionVO conditionVO) {
        return new Result(StatusConst.OK, "查询成功", menuService.listMenus(conditionVO));
    }

    // TODO
//    @ApiOperation(value = "新增修改")
//    @PostMapping ("/admin/menus")
//    public Result<List<Menu>> delOrUpdateMenu() {
//        return new Result(StatusConst.OK, "查询成功", menuService.listMenus());
//    }

    // TODO
//    @ApiOperation(value = "删除菜单")
//    @DeleteMapping("/admin/menus")
//    public Result<List<Menu>> deleteMenu() {
//        return new Result(StatusConst.OK, "查询成功", menuService.listMenus());
//    }

    @ApiOperation(value = "查看角色菜单选项")
    @GetMapping("/admin/role/menus")
    public Result<List<Menu>> listMenusWithRole() {
        return new Result(StatusConst.OK, "查询成功", menuService.getMenusWithRole());
    }

    @ApiOperation(value = "查看用户菜单")
    @GetMapping("/admin/user/menus")
    public Result<List<Menu>> listUserMenus() {
        return new Result(StatusConst.OK, "查询成功", menuService.listUserMenus());
    }
}
